//package com.xzx.shop_front_api.consumer;
//
//import com.google.gson.Gson;
//import com.xzx.shop_front_api.entity.Messages;
//import com.xzx.shop_front_api.service.MessageService;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.stereotype.Component;
//
//@Component
//public class RabbitMQConsumer {
//
//    private final MessageService messageService;
//
//    public RabbitMQConsumer(MessageService messageService) {
//        this.messageService = messageService;
//    }
//
//    // 监听指定队列的消息
//    @RabbitListener(queues = "${rabbitmq.queue.name}")
//    public void consumeMessage(String message) {
//        System.out.println("接收到消息: " + message);
//        // 这里可以添加消息处理逻辑
//        Gson gson = new Gson();
//        Messages objMessage = gson.fromJson(message, Messages.class);
//        messageService.insertMessage(objMessage);
//    }
//}
